﻿using System;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;

using Telerik.WebControls;
using UFSoft.UBF.UI.WebControls;
using UFSoft.UBF.UI.Controls;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.Util.Globalization;

using UFSoft.UBF.UI.IView;
using UFSoft.UBF.UI.Engine;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.UI.WebControls.ClientCallBack;
using UFIDA.U9.UI.PDHelper;
using UFIDA.U9.Cust.SH.SHFastShipBP.Proxy;
using System.Collections.Generic;
using UFIDA.U9.Cust.SH.SHFastShipUI.Pub;



/***********************************************************************************************
 * Form ID: 
 * UIFactory Auto Generator 
 ***********************************************************************************************/
namespace UFIDA.U9.Cust.SH.SHFastShipBListUIModel
{
    public partial class SHFastShipBListUIFormWebPart
    {
        #region Custome eventBind



        //BtnNew_Click...
        private void OnHold_Click_Extend(object sender, EventArgs e)
        {
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.
            this.Model.ClearErrorMessage();

            List<long> ids = new List<long>();
            IList<IUIRecord> list = this.Model.SHFastShip.Cache.GetSelectRecord();
            foreach (IUIRecord record in list)
            {
                long id = PubTool.ToLong(record["MainID"].ToString());
                if (!ids.Contains(id) && id > 0)
                {
                    ids.Add(id);

                    try
                    {
                        HoldProxy proxy = new HoldProxy();
                        proxy.FastShipID = id;
                        proxy.Do();
                    }
                    catch (Exception ex)
                    {
                        IUIRecord rec = record;
                        IUIModel model = this.Model;
                        this.Model.ErrorMessage.SetErrorMessage(ref rec, "ID", ex.Message);
                        this.Model.ErrorMessage.SetErrorMessage(ref model, ex.Message);
                    }
                }
            }

            this.Action.NavigateAction.Refresh(null, true);

            OnHold_Click_DefaultImpl(sender, e);
        }

        //BtnDelete_Click...
        private void OnUnHold_Click_Extend(object sender, EventArgs e)
        {
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.

            this.Model.ClearErrorMessage();

            List<long> ids = new List<long>();
            IList<IUIRecord> list = this.Model.SHFastShip.Cache.GetSelectRecord();
            foreach (IUIRecord record in list)
            {
                long id = PubTool.ToLong(record["MainID"].ToString());
                if (!ids.Contains(id) && id > 0)
                {
                    ids.Add(id);

                    try
                    {
                        UnHoldProxy proxy = new UnHoldProxy();
                        proxy.FastShipID = id;
                        proxy.Do();
                    }
                    catch (Exception ex)
                    {
                        IUIRecord rec = record;
                        this.Model.ErrorMessage.SetErrorMessage(ref rec, "ID", ex.Message);
                    }
                }
            }

            this.Action.NavigateAction.Refresh(null, true);

            OnUnHold_Click_DefaultImpl(sender, e);
        }	

				//BtnNew_Click...
		private void BtnNew_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.

            NavigateManager.NavigatePage(this, "UFIDA.U9.Cust.SH.SHFastShip");
			BtnNew_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnDelete_Click...
		private void BtnDelete_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnDelete_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnOutPut_Click...
		private void BtnOutPut_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnOutPut_Click_DefaultImpl(sender,e);
		}	
		 
				//BtnPrint_Click...
		private void BtnPrint_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			BtnPrint_Click_DefaultImpl(sender,e);
		}	
		 

			

		//DDLCase_TextChanged...
		private void DDLCase_TextChanged_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			DDLCase_TextChanged_DefaultImpl(sender,e);
		}	
		 
				//OnLookCase_Click...
		private void OnLookCase_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			OnLookCase_Click_DefaultImpl(sender,e);
		}	
		 
			
				

		//DataGrid1_GridRowDbClicked...
		private void DataGrid1_GridRowDbClicked_Extend(object sender, GridDBClickEventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
            //通过this.CurrentModel.ViewName访问到记录的MainID字段，一定是MainID
            string DataID = this.Model.SHFastShip.FocusedRecord["MainID"].ToString();
            //单据页面装配的URI
            string CardPageID = "UFIDA.U9.Cust.SH.SHFastShip";
            OnNavigatCard("Browse", DataID, CardPageID);

		
			DataGrid1_GridRowDbClicked_DefaultImpl(sender,e);
		}

        private void OnNavigatCard(string type, string dataID, string formID)
        {
            string FormID = formID;//AddFormID
            string DataID = dataID;
            if (DataID == String.Empty && type == "Browse")
            {
                return;
            }
            else
            {
                System.Collections.Specialized.NameValueCollection nameValCol = new System.Collections.Specialized.NameValueCollection();
                nameValCol.Add("PDPageStatus", type);
                nameValCol.Add("ID", DataID);
                this.NavigatePage(FormID, nameValCol);
            }
        }

		
            
            
            

		#region 自定义数据初始化加载和数据收集
		private void OnLoadData_Extend(object sender)
		{	
			OnLoadData_DefaultImpl(sender);
		}
		private void OnDataCollect_Extend(object sender)
		{	
			OnDataCollect_DefaultImpl(sender);
		}
		#endregion  

        #region 自己扩展 Extended Event handler 
		public void AfterOnLoad()
		{
			
			AfterOnLoad_Qry_DefaultImpl();//BE列表自动产生的代码
	    
		}

        public void AfterCreateChildControls()
        {
									
			AfterCreateChildControls_Qry_DefaultImpl();//BE列表自动产生的代码
		

		
        }
        
        public void AfterEventBind()
        {
        }
        
		public void BeforeUIModelBinding()
		{
								
		}

		public void AfterUIModelBinding()
		{
									
			AfterUIModelBinding_Qry_DefaultImpl();//BE列表自动产生的代码
		

		}


        #endregion
		
        #endregion
		
    }
}